<%@ page import="pojo.Question" %>
<%@ page import="java.util.List" %>
<%@ page import="static java.lang.System.out" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="org.apache.ibatis.io.Resources" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactoryBuilder" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %><%--
  Created by IntelliJ IDEA.
  User: 81116
  Date: 2023/11/29
  Time: 16:30
  To change this template use File | Settings | File Templates.
  在add_paper.jsp成功生成试卷后跳转此页面，可以查看
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查看试卷</title>
    <jsp:include page="teacher_menu.jsp"></jsp:include>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- 引入各种CSS样式表 -->
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/index.css">
    <link rel="stylesheet" href="css/font-change.css">
    <%--    图标--%>
    <link rel="stylesheet" href="icon/iconfont.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/c/font_4336496_3iu2a7l8bg8.css">
    <!--引入jquery和bootstrap -->
    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>

    <style>
        .my-paper{
            margin-left: 20%;
            width: 75%;
            background-color: ivory;
        }
        .small-title{
            font-size: 25px;
        }
        .question-title{
            font-size: 20px;
            background-color: #b3d4fc;
        }
        .question-content{
            font-size: 15px;
            color: #245269;
        }
        .question-answer{
            font-size: 20px;
            color: #4cae4c;
        }

    </style>
</head>
<body>
<%
    String mess=(String)session.getAttribute("message");
    if(mess!=null && !"".equals(mess)){
%>
<script type="text/javascript">
    alert("<%=mess%>");
</script>
<%
        session.setAttribute("message", "");
    } %>


<%
    List<Question> questionList= (List<Question>) session.getAttribute("questionList");//获取到该卷纸对应的试题集合
%>
<div style="margin-left: 20%;margin-top:10px;width: 75%;height:80px;background-color: #66afe9;">
    <h2 style="text-align: center;padding-top: 25px">
        <%
            String resource = "mybatis-config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resource);
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            SqlSession sqlSession = sqlSessionFactory.openSession();
            String p_name=(String)session.getAttribute("p_name");
            System.out.println("前端watch_paper_content:"+p_name);
            int p_id=sqlSession.selectOne("mapper.Paper.findPaperIdByName",p_name);
        %>
        <%=p_name%>
    </h2>
</div>
<br>
<div style="margin-left: 20%">
    <button type="button" class="btn btn-success" onclick="window.location.href='loadPaperList'">返回</button>
    <button type="button" class="btn btn-success" onclick="location.href='loadPaperContent?p_id=<%=p_id%>">刷新</button>
</div>
<div class="my-paper">
    <div class="small-title">
        一、单选题<br><br>
    </div>
    <div class="content">
        <%
            int i=1;//i,j,k分别代表单选题多选题，判断题的题号，从1开始数量增加
            for(Question c1:questionList){
                if(c1.getQ_type().equals("单选题")){
        %>
        <div class="question-title">
            <%=i%>.题目：<%=c1.getQ_content()%><br>
        </div>
        <div class="question-content">
            A.<%=c1.getOp_A()%><br>
            B.<%=c1.getOp_B()%><br>
            C.<%=c1.getOp_C()%><br>
            D.<%=c1.getOp_D()%><br>
            <div class="question-answer">
                标准答案：<%=c1.getQ_standard()%><br><br>
            </div>
        </div>
        <%
                    i++;
                }}if(i==1){//没有单选题
        %>
        该试卷不包含单选题哦~<br><br>
        <%
            }
        %>
    </div>
    <div class="small-title">
        二、多选题<br><br>
    </div>
    <div class="content">
        <%
            int j=1;//i,j,k分别代表单选题多选题，判断题的题号，从1开始数量增加
            for(Question c2:questionList){
                if(c2.getQ_type().equals("多选题")){
        %>
        <div class="question-title">
            <%=j%>.题目：<%=c2.getQ_content()%><br>
        </div>
        <div class="question-content">
            A.<%=c2.getOp_A()%><br>
            B.<%=c2.getOp_B()%><br>
            C.<%=c2.getOp_C()%><br>
            D.<%=c2.getOp_D()%><br>
            <div class="question-answer">
                标准答案：<%=c2.getQ_standard()%><br><br>
            </div>
        </div>
        <%
                    j++;
                }}
            if(j==1){//没有多选题
        %>
        该试卷不包含多选题哦~<br><br>
        <%
            }
        %>
    </div>
    <div class="small-title">
        三、判断题<br><br>
    </div>
    <div class="content">
        <%
            int k=1;//i,j,k分别代表单选题多选题，判断题的题号，从1开始数量增加
            for(Question c3:questionList){
                if(c3.getQ_type().equals("判断题")){
        %>
        <div class="question-title">
            <%=k%>.题目：<%=c3.getQ_content()%><br>
        </div>
        <div class="question-content">
            A.<%=c3.getOp_A()%><br>
            B.<%=c3.getOp_B()%><br>
            C.<%=c3.getOp_C()%><br>
            D.<%=c3.getOp_D()%><br>
            <div class="question-answer">
                标准答案：<%=c3.getQ_standard()%><br><br>
            </div>
        </div>
        <%
                    k++;
                }}if(k==1){//没有判断题
        %>
        该试卷不包含判断题哦~<br><br>
        <%
            }
        %>
    </div>
</div>
</body>
</html>
